<?php

use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;

/**
 * Class CreateOrderProductsTable.
 */
class CreateOrderProductsTable extends Migration
{
	/**
	 * Run the migrations.
	 *
	 * @return void
	 */
	public function up()
	{
		Schema::create('order_products', function(Blueprint $table) {
            $table->increments('id');
            $table->integer('user_id')->comment('用户id');
            $table->string('order_code',64)->comment('订单编号');
            $table->integer('product_id')->comment('产品id');
            $table->integer('sku_id')->comment('sku_id');
            $table->string('product_name',64)->comment('产品名称');
            $table->string('model',64)->comment('型号');
            $table->string('brand_name',64)->comment('品牌名称');
            $table->integer('shop_id')->comment('店铺id');
            $table->string('shop_name',64)->comment('店铺名称');
            $table->string('product_img_url')->comment('产品图片地址');
            $table->decimal('product_price',10,2)->comment('产品价钱');
            $table->decimal('discount_money',10,2)->default(0.00)->comment('优惠金额');
            $table->integer('quantity')->comment('数量');
            $table->decimal('product_money',10,2)->default(0.00)->comment('产品总金额');
            $table->text('attributes')->comment('属性');
            $table->string('remark',256)->comment('备注')->nullable();
            $table->tinyInteger('is_appraise')->default(0)->comment('是否已评价  0：未评价  1：已评价');

            $table->timestamps();
            $table->softDeletes();
            $table->index('order_code');
            $table->index('user_id');
            $table->engine = 'InnoDB';
		});
	}

	/**
	 * Reverse the migrations.
	 *
	 * @return void
	 */
	public function down()
	{
		Schema::drop('order_products');
	}
}
